package com.td.module.produce.dal.mysql.inputhusbandry;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.produce.controller.admin.inputhusbandry.vo.InputHusbandryExportReqVO;
import com.td.module.produce.controller.admin.inputhusbandry.vo.InputHusbandryPageReqVO;
import com.td.module.produce.dal.dataobject.inputhusbandry.InputHusbandryDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 投入品与农事中间 Mapper
 *
 * @author 王翔翔
 */
@Mapper
public interface InputHusbandryMapper extends BaseMapperX<InputHusbandryDO> {

    default PageResult<InputHusbandryDO> selectPage(InputHusbandryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InputHusbandryDO>()
                .eqIfPresent(InputHusbandryDO::getInputId, reqVO.getInputId())
                .eqIfPresent(InputHusbandryDO::getHusbandryId, reqVO.getHusbandryId())
                .betweenIfPresent(InputHusbandryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InputHusbandryDO::getId));
    }

    default List<InputHusbandryDO> selectList(InputHusbandryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InputHusbandryDO>()
                .eqIfPresent(InputHusbandryDO::getInputId, reqVO.getInputId())
                .eqIfPresent(InputHusbandryDO::getHusbandryId, reqVO.getHusbandryId())
                .betweenIfPresent(InputHusbandryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InputHusbandryDO::getId));
    }

}
